package cn.itcast.scala.course09
import java.io.{FileInputStream, InputStreamReader}

import scala.xml.XML
/**
  * scala操作XML文件
  * scala.xml包在scala2.10版本之后被移出来了，需要使用时单独引用scala-xml的包
  * create by zhangtian on 2019/1/10
  */
object XMLApp {

  def main(args: Array[String]): Unit = {
    loadXML()
  }

  // 载入并打印XML文件内容
  def loadXML(): Unit ={
    // val xml = XML.load(this.getClass.getClassLoader.getResource("test.xml"))
    // val xml = XML.load(new FileInputStream("D:\\Developer\\IDEAWorkspace\\LearningScala2.11.12\\scala-train\\src\\main\\resources\\test.xml"))
    val xml = XML.load(new InputStreamReader(new FileInputStream("D:\\Developer\\IDEAWorkspace\\LearningScala2.11.12\\scala-train\\src\\main\\resources\\test.xml")))

    println(xml)
  }
}
